<template>
  <div id="usualgeometry"></div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'

const scene = new THREE.Scene()
const geometry = new THREE.BoxGeometry(10, 10, 10, 5, 5, 5);
const solidMaterial = new THREE.MeshBasicMaterial(
  {
    color: '#2b7098',
    transparent: true,
    opacity: 0.8,
  }
)
const wireframeMaterial = new THREE.MeshBasicMaterial(
  {
    color: 'white',
    wireframe: true
  }
)

const solidMesh = new THREE.Mesh(geometry, solidMaterial)
const wireframeMesh = new THREE.Mesh(geometry, wireframeMaterial)
scene.add(solidMesh)
scene.add(wireframeMesh)

const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.set(0, 0, 20)

const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)

const animate = () => {
    requestAnimationFrame(animate)
    solidMesh.rotation.x += 0.01
    solidMesh.rotation.y += 0.01
    solidMesh.rotation.z += 0.01
    wireframeMesh.rotation.x += 0.01
    wireframeMesh.rotation.y += 0.01
    wireframeMesh.rotation.z += 0.01
    renderer.render(scene, camera)
}

window.onresize = () => {
    renderer.setSize(window.innerWidth, window.innerHeight)
    camera.aspect = window.innerWidth / window.innerHeight
    camera.updateProjectionMatrix()
}

onMounted(() => {
    new OrbitControls(camera, renderer.domElement)
    document.getElementById('usualgeometry').appendChild(renderer.domElement)
    animate()
})
</script>

<style>

</style>